package impl_v1;

import model.AuctionPrivate;
import model.AuctionPublic;
import model.Bid;
import model.Item;

public class AuctionPublicImpl implements AuctionPublic {

	private static final long serialVersionUID = 4253701275636430194L;
	private final int startingPrice;
	private Bid bid;
	private final Item item;
	
	protected boolean closed = false;
	
	public AuctionPublicImpl(int startingPrice, Item item) {
		super();
		this.startingPrice = startingPrice;
		this.bid = null;
		this.item = item;
	}
	
	public AuctionPublicImpl(AuctionPrivate auctionPrivate) {
		super();
		this.startingPrice = auctionPrivate.getStartingPrice();
		this.bid = auctionPrivate.getBid();
		this.item = auctionPrivate.getItem();
	}

	@Override
	public Bid getBid() {
		return bid;
	}

	@Override
	public void setBid(Bid bid) {
		this.bid = bid;
	}

	@Override
	public boolean hasBid() {
		return bid != null;
	}
	
	@Override
	public int getStartingPrice() {
		return startingPrice;
	}

	@Override
	public Item getItem() {
		return item;
	}

	public boolean isClosed() {
		return closed;
	}
	
	@Override
	public String toString() {
		return "AuctionPublicImpl[startingPrice=" + startingPrice + ", bid="+ bid + ", item=" + item + ", closed=" + closed + "]";
	}
}
